\section{First Class Module}

First class mdoule  means module could be passed as a parameter.

Here is a simple example

\inputminted[fontsize=\scriptsize, ]{ocaml}{lang/code/module/intro.ml}

 
Here the argument \verb|m| is a module. This is already possible with
objects and records, but now modules are also allowed.  We introduce
three syntaxes

\begin{ocamlcode}
  (module module_expr: package_type)
  (*packing:  mdoule -> expression *)
  (val expr: package_type)
  (*unpacking: expression -> module  *)
  (module package_type)
  (*a new syntax to type-expr*)
\end{ocamlcode}


Parametric algorithms
\inputminted[fontsize=\scriptsize, fontsize=\scriptsize, ]{ocaml}{code/lang/param.ml}

Notice \verb|with type t = int| is necessary here.

The next is a fancy example to illustrate lebiniz equivalence, readers
should try to digest it. Something to reminder, now the simple type
may be a very complex module type.
\begin{ocamlcode}
type ('a, 'b) eq = (module EqTC with type a = 'a and type b = 'b)))
\end{ocamlcode}


\inputminted[fontsize=\scriptsize, fontsize=\scriptsize, ]{ocaml}{lang/code/module/leibniz.ml}


%%% Local Variables: 
%%% mode: latex
%%% TeX-master: "../master"
%%% End: 
